// --------------------------------------------------------------------------------------------------------------------- 
// <copyright file="SyncAll.asmx.cs" company="Scrum for Team System">
//   None
// </copyright>
// <summary>
//   Defines the SyncAll type.
// </summary>
// ---------------------------------------------------------------------------------------------------------------------
namespace ScrumForTeamSystem.EventService.WebService
{
    using System.ComponentModel;
    using System.Web.Services;

    using Infrastructure;
    using Infrastructure.Interfaces;

    using ScrumForTeamSystem.EventService.Services;

    /// <summary>
    /// The sync all web service end point class.
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [ToolboxItem(false)]
    public class SyncAll : WebService
    {
        /// <summary>
        /// Starts the process.
        /// </summary>
        /// <param name="tfsAddress">The team foundation server url.</param>
        /// <param name="projectName">The project name.</param>
        /// <returns>Process enqued messge.</returns>
        [WebMethod]
        public string Start(string tfsAddress, string projectName)
        {
            var queueService = DependencyResolver.GetImplementation<IEventQueueService>();

            var tfsIdentity = new TFSIdentity { Url = tfsAddress };
            var swrEvent = new SyncAllEvent { ProjectName = projectName };

            queueService.Enqueue(swrEvent, tfsIdentity);

            return "Synchronization event added to process queue.";
        }
    }
}